package com.zqy.controller;

import java.sql.*;

public class KingbaseJdbcExample {
    public static void main(String[] args) {
        // 数据库URL，格式为：jdbc:kingbase://hostname:port/databaseName192.168.95.131:54321/test 123
        String jdbcUrl = "jdbc:kingbase8://192.168.95.131:54321/zqy_js";
        String username = "root";
        String password = "Js@940209";
        try {
            // 加载并注册JDBC驱动
            Class.forName("com.kingbase8.Driver");
            // 建立数据库连接
            Connection conn = DriverManager.getConnection(jdbcUrl, username, password);
            Statement stmt = conn.createStatement();
            // 操作数据库...
            String sql = "select * from zqy_homepageimgs";
            ResultSet rs  =stmt.executeQuery(sql);
//            测试git提交 打印输出
            System.out.println(rs);
            while (rs.next()){
                String imgname = rs.getString("imgname");
                System.out.println(imgname);
            }
            // 关闭连接
            conn.close();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}